import java.awt.Graphics;
import java.awt.Image;
import java.util.Random;
import java.awt.*;
import java.applet.Applet;



public class BJ4canvas extends java.applet.Applet
{
	Container myContainer=new Container();
    Image mypic;

	public void init()
	{

		Canvas mycanvas = new Canvas();


		int [] hearts = new int [13]; // this does an array
	int [] diamonds = new int [13];
	int [] clubs = new int [13];
	int [] spades = new int [13];
	//System.out.println("First card is a " +hearts[1]);
	int  x;
	int y=0;
	String suit=" ";
	String value=" ";
	String card=" ";
	int [] player1=new int[5];
	int [] player2=new int[5];

	Random Generate1= new Random();
	y=(int)(Generate1.nextDouble()*13)+1;
	x=(int)(Generate1.nextDouble()*4)+1; //4because 4 suits
	//System.out.println(x);
	if (x==1)
		suit="H"; //suit is hearts
	if (x==2)
		suit="D"; //suit is diamonds
	if (x==3)
		suit="C"; //suit is clubs
	if (x==4)
		suit="S"; //suit is spades
	if(y==1)
		value="01";
	if(y==2)
		value="02";
	if(y==3)
		value="03";
	if(y==4)
		value="04";
	if(y==5)
		value="05";
	if(y==6)
		value="06";
	if(y==7)
		value="07";
	if(y==8)
		value="08";
	if(y==9)
		value="09";
	if(y==10)
		value="10";
	if(y==11)
		value="11";
	if(y==12)
		value="12";
	if(y==13)
		value="13";
	card=suit+value + ".jpg";
	//System.out.println(card);
	//System.out.println(y + " " + suit);  //must have the space to show the characters
          mycanvas.setBackground(Color.pink);
          mycanvas.setSize(150,150);
		  mypic = getImage(getCodeBase(),card);
		  //paint.add(mycanvas);//.add(repaint);
		  myContainer.setBackground(Color.blue);
		  myContainer.setSize(150,150);
		  add(myContainer);

		  //add(mycanvas);
	}

	  public void paint(Graphics screen)
	  	{
	        //Image mypic= BJ4canvas.mypic;
	  		int iWidth =mypic.getWidth(this);
	  		int iHeight=mypic.getHeight(this);
	  		int xPos = 10;
	  		screen.drawImage(mypic, xPos,10, this);
		}
}
